﻿using System;
using System.Drawing;
using System.Xml.Serialization;

namespace MobileCarManager.MobileControls.Styles
{
  /// <summary>Implements the style data structure for a button.</summary>
  [Serializable]
  public class ButtonStyle
  {
    /// <summary>Constructor.</summary>
    public ButtonStyle()
    {
      this.Border = new BorderStyle();
      this.BackgroundGradient = new GradientStyle();
      this.BackgroundGradient.Gradient.Add(Color.Black);
      this.BackgroundGradient.Gradient.Add(Color.DarkGray);
      this.BackgroundGradient.Gradient.Add(Color.Black);
      this.Font = new Font(FontFamily.GenericSansSerif, 10.0f, FontStyle.Regular);
      this.TextColor = Color.White;
    }

    /// <summary>Returns the style of the border.</summary>
    [XmlElement("Border")]
    public BorderStyle Border { get; set; }

    /// <summary>Returns the gradient of the button background.</summary>
    [XmlElement("BackgroundGradient")]
    public GradientStyle BackgroundGradient { get; set; }

    /// <summary>Returns the text color.</summary>
    [XmlIgnore]
    public Color TextColor { get; set; }

    /// <summary>
    /// Returns the text color in a serializable form. This property is used for
    /// serialization.
    /// </summary>
    [XmlElement("TextColor")]
    public string SerializableTextColor
    {
      get { return StyleManager.SerializeColor(this.TextColor); }
      set { this.TextColor = StyleManager.DeserializeColor(value); }
    }

    /// <summary>Returns the font of the button text.</summary>
    [XmlIgnore]
    public Font Font { get; set; }

    /// <summary>
    /// Returns the font of the button text in a serializable form. This property is used
    /// for serialization.
    /// </summary>
    [XmlElement("Font")]
    public string SerializableFont
    {
      get { return StyleManager.SerializeFont(this.Font); }
      set { this.Font = StyleManager.DeserializeFont(value); }
    }
  }
}
